﻿#pragma warning disable 0168
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Celeriq.Client.Interfaces;
using Celeriq.Common;

namespace Celeriq.HostConsole
{
    internal static class Tester
    {
        public static UserCredentials Credentials
        {
            get
            {
                try
                {
                    using (var factory = SystemCoreInteractDomain.GetFactory("localhost"))
                    {
                        var server = factory.CreateChannel();
                        var credentials = new UserCredentials();
                        credentials.UserName = "root";
                        credentials.Password = "password";
                        credentials.Password = Celeriq.Utilities.SecurityHelper.Encrypt(server.GetPublicKey(), credentials.Password);
                        return credentials;
                    }
                }
                catch (Exception ex)
                {
                    return null;
                }
            }
        }

        public static string PublicKey
        {
            get
            {
                try
                {
                    using (var factory = SystemCoreInteractDomain.GetFactory("localhost"))
                    {
                        var server = factory.CreateChannel();
                        return server.GetPublicKey();
                    }
                }
                catch (Exception ex)
                {
                    return string.Empty;
                }
            }
        }

    }
}